package com.example.springboot.prop;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 使用{@link PropertySource }和 {@link ConfigurationProperties} 读取自定义配置文件 。
 * <p> 注意：使用自定义配置文件时，在自定义配置文件里的属性名不要与主配置里的属性名重复，
 * 否则会被主配置里的值给覆盖。
 * <p> 即在同名的情况下，主配置文件里的属性值优先级高。
 * <p>
 * @author Zhang.Z
 * @version 2025-09-19
 */

@Component
@PropertySource(value = {"classpath:userinfo.properties"}, encoding = "utf-8")
@ConfigurationProperties(prefix = "userinfo3")
public class CustomProperty {

    private String username;
    private Integer age;
    private Boolean active;
    private Map<String, Object> map;
    private Date createdDate;
    private List<String> hobbies;
    private LocalDateTime jdk8date;


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    public LocalDateTime getJdk8date() {
        return jdk8date;
    }

    public void setJdk8date(LocalDateTime jdk8date) {
        this.jdk8date = jdk8date;
    }


}
